﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using HoneyBadgersOfficePlayer.Models;

namespace HoneyBadgersOfficePlayer.Views
{
    public partial class CreateRoom : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            string roomName = Room_Name.Text;
            string maxUsers = Max_Users.Text;
            bool privateRoom;
            if (Private_Room.Checked)
                privateRoom = true;
            else
                privateRoom = false;
            string password = Password.Text;

            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("@Name", roomName));
            parameterList.Add(new SqlParameter("@User_ID", Globals.UserID));
            parameterList.Add(new SqlParameter("@Max_Users", maxUsers));
            parameterList.Add(new SqlParameter("@Password", password));
            parameterList.Add(new SqlParameter("@Private", privateRoom));

            SqlParameter outputParameter = new SqlParameter("@var1", SqlDbType.Int);

            int roomID = SQLUtilities.RunStoredProcedure("CreateRoom", parameterList, outputParameter);

            Globals.RoomID = roomID;

            Response.Write("<script type='text/javascript'>window.open('StreamDemo.aspx','_self');</script>");
        }

    }
}